package com.example.administrator.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
      EditText mEtUserName;
      EditText mEtPassword;
    Button mBtnLogin;
    Button mBtnCancel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initEvent();
    }
    private void initEvent(){
        mBtnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               String userName=mEtUserName.getText().toString();
                String pasword=mEtPassword.getText().toString();
                if(userName.equals("admin")&&pasword.equals("123")){
                    Intent intent=new Intent(MainActivity.this,TeamsActivity.class);
                    startActivity(intent);
                }else {
                    Toast.makeText(MainActivity.this, "用户输入错误", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
    private void initView(){
        mEtUserName= (EditText) findViewById(R.id.et_user_name);
        mEtPassword= (EditText) findViewById(R.id.et_password);
        mBtnLogin= (Button) findViewById(R.id.btn_login);
        mBtnCancel= (Button) findViewById(R.id.btn_cancel);
    }
}
